package com.itlong.cloud.property.resource;

import com.itlong.cloud.POJO.DTO.property.PropertyCloudServiceCastMessagePageDTO;
import com.itlong.cloud.POJO.DTO.property.PropertyCloudServiceCostSaveOrderDTO;
import com.itlong.cloud.POJO.DTO.property.PropertyInvoiceInfoDTO;
import com.itlong.cloud.POJO.PO.PropertyCloudServiceCostOrderInfoPO;
import com.itlong.cloud.POJO.VO.property.PropertyCloudServiceCostPaymentByPageVO;
import com.itlong.cloud.POJO.VO.property.PropertyCloudServiceCostRecordByPageVO;
import com.itlong.cloud.paymenthub.IPropertyCloudServiceCostServiceClient;
import com.itlong.cloud.property.service.IPropertyCloudServiceCostService;
import com.itlong.cloud.utils.page.Page;
import com.itlong.cloud.utils.page.PageByVisitor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <desc>
 *      云服务费支付接口暴露接口
 * </desc>
 *
 * @createDate 2019/8/12
 */
@RestController
public class PropertyCloudServiceCostResource implements IPropertyCloudServiceCostServiceClient {

    @Autowired
    IPropertyCloudServiceCostService iPropertyCloudServiceCostService;

    /**
     * <desc>
     *      获取云服务费的订单列表。
     * <desc/>
     *
     * @param  projectId 项目ID
     * @param  currentPage 当前页
     * @param  pageSize 页面大小
     * @param  feeStatus 查询条件 1待缴费 2全部
     * @param  orderColumn 排序条件
     * @param  orderRule 排序规则 ASC DESC
     * @return
     * @author Juguang.S
     * @createDate 2019-11-22
     */
    @Override
    @PostMapping(path = "/pay/getOrderInfo")
    public PageByVisitor<PropertyCloudServiceCostPaymentByPageVO> getOrderInfo(@RequestParam("projectId") String projectId,
                                                                               @RequestParam(value = "currentPage",required = false) String currentPage,
                                                                               @RequestParam(value = "pageSize",required = false) String pageSize,
                                                                               @RequestParam("feeStatus") String feeStatus,
                                                                               @RequestParam(value = "orderId",required = false) String orderId,
                                                                               @RequestParam(value = "orderColumn",required = false) String orderColumn,
                                                                               @RequestParam(value = "orderRule",required = false) String orderRule) throws Exception{
        return iPropertyCloudServiceCostService.getOrderInfo(projectId,currentPage,pageSize,feeStatus,orderId,orderColumn,orderRule);
    }

    /**
     * <desc>
     *      修改线下银行支付订单
     * <desc/>
     *
     * @param  orderDTO 订单
     * @return
     * @author Juguang.S
     * @createDate 2019/8/12
     */
    @Override
    @PostMapping(path = "/pay/saveCloudServiceOrder")
    public String saveOrder(@RequestBody PropertyCloudServiceCostSaveOrderDTO orderDTO) throws Exception {
        return iPropertyCloudServiceCostService.saveOrder(orderDTO);
    }

    /**
     * <desc>
     *      获取物业云服务费续费记录分页信息。
     * <desc/>
     *
     * @param  pageDTO 请求参数
     * @return
     * @author Juguang.S
     * @createDate 2019-08-12
     */
    @Override
    @PostMapping(path = "/pay/getPaymentRecordByPage")
    public Page<PropertyCloudServiceCostRecordByPageVO> getPaymentRecordByPage(@RequestBody PropertyCloudServiceCastMessagePageDTO pageDTO) throws Exception {
        return iPropertyCloudServiceCostService.getPaymentRecordByPage(pageDTO);
    }

    /**
     * <desc>
     *      检测是否还有未支付的结下账单
     * <desc/>
     *
     * @param  projectId 项目编号
     * @return
     * @author Juguang.S
     * @createDate 2019/8/21
     */
    @Override
    @PostMapping(path = "/pay/getIsBankPayOrder")
    public Integer getIsBankPayOrder(@RequestParam("projectId") String projectId){
        return iPropertyCloudServiceCostService.getIsBankPayOrder(projectId);
    }

    /**
     * <desc>
     *      保存物业发票信息。
     * <desc/>
     *
     * @param  dto 物业发票信息
     * @return
     * @author Juguang.S
     * @createDate 2019-11-22
     */
    @Override
    @PostMapping(path = "/pay/addInvoiceInfo")
    public Integer addInvoiceInfo(@RequestBody PropertyInvoiceInfoDTO dto) throws Exception{
        return iPropertyCloudServiceCostService.addInvoiceInfo(dto);
    }

    /**
     * <desc>
     *      根据订单ID查询订单金额及支付状态
     * <desc/>
     *
     * @param  orderId 订单Id
     * @return
     * @author Juguang.S
     * @createDate 2019/11/25
     */
    @Override
    @PostMapping(path = "/pay/getOrderAmount")
    public PropertyCloudServiceCostOrderInfoPO getOrderAmount(@RequestParam(value = "orderId",required = false) String orderId){
        return iPropertyCloudServiceCostService.getOrderAmount(orderId);
    }

}